﻿using System;
using netDxf;

namespace TestDxfDocument
{
    class Cylinder
    {
        #region 
        //圆柱面轴线单位向量
        private Vector3 axisUnitNormal;
        private Vector3 startPoint;
        private Vector3 endPoint;
        private double radius;
        #endregion

        #region constructor
        public Cylinder(Vector3 startPoint,Vector3 endPoint,double radius)
        {

            if (Vector3.Distance(startPoint, endPoint) == 0)
                throw new Exception("起始平面与终止平面重合");
            if (radius.Equals(double.NaN) || radius <= 0)
                throw new Exception("半径值"+ radius +"错误");
            //将轴线向量转换成单位向量
            axisUnitNormal = Pus.UnitVector(startPoint, endPoint);
            this.startPoint = startPoint;
            this.endPoint = endPoint;
            this.radius = radius;
        }
        #endregion

        #region public properties
        public Vector3 AxisUnitNormal { get => axisUnitNormal; set => axisUnitNormal = value; }
        public Vector3 StartPoint { get => startPoint; set => startPoint = value; }
        public Vector3 EndPoint { get => endPoint; set => endPoint = value; }
        public double Radius { get => radius; set => radius = value; }
        #endregion
    }
}
